package main.java.dao.impl;

import java.util.List;

import main.java.dao.UserDao;
import main.java.domain.User;
import main.java.utils.XMLUtils;

public class UserDaoImpl implements UserDao{
	private List<User> users;
	
	public UserDaoImpl() {
		users=XMLUtils.getUsers();
	}
	
	@Override
	public int countUserByNameAndPwd(User user) {
		if(user==null) 
			return 0;
		
		String tel=user.getTel();
		String pwd=user.getPwd();
		if(tel==null||tel.length()<=0)
			return 0;
		if(pwd==null||pwd.length()<=0)
			return 0;
		
		int res=0;
		for(User u : users) {
			if(tel.equals(u.getTel())&&pwd.equals(u.getPwd())) {
				res++;
			}
		}
		
		return res;
	}
}
